package com.kaifamiao.demo.d0820;

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

public class Demo06 {

    public static void main(String[] args) {
        Set set = new HashSet();

        set.add(1);
        set.add(1);


        System.out.println(set.add(2));
        System.out.println(set);
        System.out.println(set.size());
    }
}

class Stu{
    String name;

    int age;

    public Stu(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Stu stu = (Stu) o;
        return age == stu.age;
    }

    @Override
    public int hashCode() {
        return Objects.hash(age);
    }

    @Override
    public String toString() {
        return "Stu{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
